#pragma once
#include "archiver.h"
#include "IHTreeCallBack.h"

class FrequencyTable;
class IFTBuilder;
class IHTreeBuilder;
class HTree;

class HuffmanArchiver :
	public Archiver, public  IHTreeCallBack
{
public:
	~HuffmanArchiver(void);
	virtual void archive(DataSource* s, DataTarget* t);
	virtual void unarchive(DataSource* s, DataTarget* t);
	virtual void acceptFinishedByte(uint8_t byte);
private:
	void process(DataSource* s, DataTarget*t, IFTBuilder* ftBuilder, IHTreeBuilder* treeBuilder, ArchivingMode mode);
	FrequencyTable* table;
	// safe or not
	DataSource* source;
	DataTarget* target;
	HTree* tree;
	void writeFrequencyTable(FrequencyTable* table, DataTarget* target);
};

